package com.sdcx.agrobank.ui.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.sdcx.agrobank.MainActivity;
import com.sdcx.agrobank.R;

public class Main2Activity extends AppCompatActivity {

    private TextView view;
    private CountDownTimer timer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        view = findViewById(R.id.tiaoguo);

        timer = new CountDownTimer(3000, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {
                view.setText(millisUntilFinished/1000+1 + "S跳过");
            }

            @Override
            public void onFinish() {
                startActivity(new Intent(Main2Activity.this, Main4Activity.class));
                finish();
            }
        }.start();

    }

    @Override
    protected void onDestroy() {
        if (timer!=null){
            timer.cancel();
        }
        super.onDestroy();
    }
}